unit clsImplantacao;

interface

uses dbtables,dm,biblio;

type TImplantacao=class(tobject)
  public
   impl_descricao_menu: string;
   impl_data          : TDateTime;
   impl_usuario       : string;
   impl_identificador : string;
   impl_sequencia     : string;
   procedure Gravar   (P_impl_programa: string);
   function  Recuperar(P_impl_programa: string): boolean;
   procedure Excluir;
  end;

implementation

{ TImplantacao }

procedure TImplantacao.Excluir;
var tq: TQuery;
begin
 tq             := TQuery.create(dmint);
 tq.DatabaseName:= dmint.db.DatabaseName;
 tq.active      := false;
 tq.SQL.clear;
 tq.Params.clear;
 tq.sql.add('Delete from Implantacao');
 tq.ExecSQL;
 tq.close;
 tq.free;
end;

procedure TImplantacao.gravar;
var tq: TQuery;
begin
 tq             := TQuery.create(dmint);
 tq.DatabaseName:= dmint.db.DatabaseName;
 tq.active      := false;
 tq.sql.clear;
 tq.Params.clear;
 tq.sql.add('Insert into implantacao values('+
            ':K_impl_programa     ,'+
            ':K_impl_descricaoMenu,'+
            ':K_impl_data         ,'+
            ':K_impl_usuario      ,'+
            ':K_impl_identificador,'+
            ':K_impl_sequencia    )');
 tq.ParamByName('K_impl_programa').AsString     := copy(P_impl_programa,1,40);
 tq.ParamByName('K_impl_descricaoMenu').AsString:= impl_descricao_menu;
 tq.ParamByName('K_impl_data').AsDate           := impl_data;
 tq.ParamByName('K_impl_usuario').AsString      := impl_usuario;
 tq.ParamByName('K_impl_identificador').AsString:= impl_identificador;
 tq.ParamByName('K_impl_sequencia').AsString    := impl_sequencia;
 tq.ExecSQL;
 tq.close;
 tq.free;
end;

function TImplantacao.recuperar;
var tq: TQuery;
begin
 tq             := TQuery.create(dmint);
 tq.DatabaseName:= dmint.db.DatabaseName;
 tq.active      := false;
 tq.Params.clear;
 tq.SQL.clear;
 tq.sql.add('Select * from Implantacao where impl_programa=:K_Impl_programa');
 tq.ParamByName('K_Impl_programa').AsString := copy(P_impl_programa,1,40);
 tq.open;
 if tq.eof then result:= false else result:= true;
 impl_descricao_menu:= tq.fieldbyname('Impl_descricaoMenu').AsString;
 impl_data          := tq.fieldbyname('Impl_data').AsDateTime;
 impl_usuario       := tq.fieldbyname('Impl_usuario').AsString;
 impl_identificador := tq.fieldbyname('impl_identificador').AsString;
 impl_sequencia     := tq.fieldByName('impl_sequencia').AsString;
 tq.close;
 tq.free;
end;

end.
